<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\PublicLogSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '发布记录';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="public-log-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            'id',
            'sys_id',
            'sys_name',
            'gitee_name',
            'status',
            [
                'attribute' => 'res',
                'label' => '日志',
                'format' => 'html',
                'value' => function($model){
                    $log = json_decode($model->res, true);
                    $str = '';
                    if (isset($log[1])) {
                        $str .= $log[0].'<br/>';
                        foreach ($log[1] as $key => $value) {
                            if (is_array($value)) {
                                $value = json_encode($value);
                            }
                            $str .= $value;
                            if (is_array($value) && ($key+1) != count($value)) {
                                $str .= '<br/>';
                            }
                        }

                        return $str;
                    } else {
                        return $model->res;
                    }
                },
                'contentOptions' => [
                    'width'=>'220',
                    'style' => 'vertical-align:middle !important;',
                ],
            ],
            'ctime',
            'lutime',
        ],
    ]); ?>


</div>
